<?php
if (isset($_COOKIE["ImOnline"])){
	//print($_COOKIE["ImOnline"]);
	//print("Welcome back " . $_COOKIE["Username"]);
} else {
	die("<br>You have no access to this page. <br><a href=\"index.php\">Please go to main page</a>");
	//print($_COOKIE["imonline"]);
	};
include("../config.php");
$sid=$_POST["sid"];
$status=$_POST["status"];
$status = intval($_POST["usertype"]);

$con = mysql_connect($host, $username, $password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  };
if($status < $_COOKIE["StatusNum"]){
	mysql_select_db($db, $con);
	$sql="UPDATE users SET Status = '".$status."'  WHERE SteamID = '".$sid."'";
	$result = mysql_query($sql) or die("Error: Couldnt update user");
	header("Location: ../users.php");
}else{
	header("Location: ../users.php?error=The user you were trying to change status on has higher or equal status!");
	die("");
};
mysql_close($con);
?>